package cn.jxau.fukin.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jxau.fukin.dao.ApplyMapper;
import cn.jxau.fukin.dao.UserMapper;
import cn.jxau.fukin.model.Apply;
import cn.jxau.fukin.model.ApplyExample;
import cn.jxau.fukin.model.ApplyExample.Criteria;
import cn.jxau.fukin.model.ApplyUser;
import cn.jxau.fukin.model.User;
import cn.jxau.fukin.model.UserExample;
import cn.jxau.fukin.service.IApplyService;

@Service("applyService")
public class ApplyService implements IApplyService {

	@Autowired
	ApplyMapper applyMapper;
	@Autowired
	UserMapper userMapper;

	@Override
	public List<ApplyUser> queryApplyInfo(User user) {
		// TODO Auto-generated method stub

		UserExample userExample = new UserExample();
		cn.jxau.fukin.model.UserExample.Criteria createCriteria = userExample.createCriteria();
		if (user.getuName() != null && user.getuName().trim() != "") {
			createCriteria.andUNameEqualTo(user.getuName());
		}
		List<User> user01 = userMapper.selectByExample(userExample);

		ApplyExample example = new ApplyExample();
		Criteria criteria = example.createCriteria();

		criteria.andUNameEqualTo(user.getuName());
		List<Apply> list = applyMapper.selectByExample(example);
		List<ApplyUser> applyUserList = new ArrayList<ApplyUser>();
		for (Apply list01 : list) {

			ApplyUser applyUser = new ApplyUser();
			applyUser.setApply(list01);
			applyUser.setUser(user01.get(0));

			applyUserList.add(applyUser);
		}
		return applyUserList;
	}
}
